<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
%>
<!DOCTYPE html>
<html>
	<head lang="en">
	    <meta charset="UTF-8">
	    <title>修改密码</title>
		<jsp:include page="../common/top.jsp"></jsp:include>
  	</head>
	<body class="page-content ">
		<div class="page-content-area" data-ajax-content="true">
			<div class="page-header">
				<h1>修改密码</h1>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<form id="_editForm" class="form-horizontal" role="form" validate="true">
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">修改密码</label>
							<div class="col-sm-9">
								<div class="clearfix help-validate">
									<input type="password" name="password" value="" required="true" 
									maxlength="100" minlength="6" placeholder="修改密码" class="col-xs-10 col-sm-5">
								</div>
							</div>
						</div>
						
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">站确认密码</label>
							<div class="col-sm-9">
								<div class="clearfix help-validate">
									<input type="password" name="rePassword" value="" required="true" 
									maxlength="100" minlength="6" placeholder="修改密码" class="col-xs-10 col-sm-5">
								</div>
							</div>
						</div>
						
								
						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button id="_submit" class="btn btn-info" type="button" data-loading-text="正在提交..." permission="/site/save">
									<i class="ace-icon fa fa-check bigger-110"></i>
									提交
								</button>
							</div>
						</div>
						
					</form>
				</div>
			</div>
		</div>
		<jsp:include page="../common/bottom.jsp"></jsp:include>
		<script type="text/javascript">
			jQuery(function($) {
				
				// 提交
				$("#_submit").click(function(){
					
					var password = $("input[name='password']").val();
					var rePassword = $("input[name='rePassword']").val();
					if(password==rePassword){
						if($('#_editForm').validate()){
							var btn = $(this);
							btn.button('loading');
							$.post("${path}/admin/updatePassword", 
									$.formJson('_editForm'),function(d) {
								if(d){
									btn.button('reset');
									if(d.status == '0000'){
										$.gritter.add({text: "修改成功"});
										/* $('input[name="id"]').val(d.data); */
	 									location.href = "${path }/logout";
									}else {
										$.gritter.add({text: d.message});
									}
								}
					        },'json');
						}
					}else{
						$.gritter.add({text: "两次密码不一致"});
					}
				
				});
			});
		</script>
	</body>
</html>

